<template>
<div>
  <van-form>
    <van-field
        v-show="obj.type===2"
        v-model="form.company"
        placeholder="请输入您的公司名称"
        :rules="[{ required: true, message: '请填写用户名' }]">
      <van-icon slot="label" name="manager-o" />
    </van-field>
    <van-field
        v-model="form.name"
        placeholder="请输入您的用户名"
        :rules="[{ required: true, message: '请填写用户名' }]">
      <van-icon slot="label" name="manager-o" />
    </van-field>
    <van-field
        v-show="obj.type===1||obj.type===3"
        v-model="form.jobNumber"
        placeholder="请输入您的工号"
        :rules="[{ required: true, message: '请输入您的工号' }]">
      <van-icon slot="label" name="birthday-cake-o" />
    </van-field>
    <van-field
        v-model="form.phone"
        placeholder="请输入您的手机号"
        :rules="[{ required: true, message: '请填写用户名' }]">
      <van-icon slot="label" name="phone-circle-o" />
    </van-field>
    <van-field
        v-model="form.code"
        placeholder="验证吗"
        :rules="[{ required: true, message: '请填写用户名' }]">
      <van-icon slot="label" name="smile-comment-o" />
      <van-button slot="button" size="mini" color="#c7bb73">发送验证吗</van-button>
    </van-field>
    <van-field readonly @click="show = true" :value="form.staffType" v-show="obj.type===3"  placeholder="网点人员类型">
      <van-icon slot="label" name="apps-o" />
      <van-icon slot="right-icon" name="arrow-down" />
    </van-field>
    <van-field
        v-show="obj.type===2||obj.type===3"
        v-model="form.org"
        placeholder="请输入您的区域"
        :rules="[{ required: true, message: '请填写用户名' }]">
      <van-icon slot="label" name="smile-comment-o" />
    </van-field>
    <van-field
        v-show="obj.type===3"
        v-model="form.dealerCode"
        placeholder="请输入您的网点编码"
        :rules="[{ required: true, message: '请输入您的网点编码' }]">
      <van-icon slot="label" name="smile-comment-o" />
    </van-field>
    <van-field
        v-show="obj.type===3"
        v-model="form.dealerName"
        placeholder="请输入您的营业网点"
        :rules="[{ required: true, message: '请输入您的营业网点' }]">
      <van-icon slot="label" name="smile-comment-o" />
    </van-field>
    <div class="form-footer">
      <van-button color="#c7bb73" @click="$emit('rest')">上一步</van-button>
      <van-button color="#c7bb73" @click="renzheng">认 证</van-button>
    </div>
  </van-form>
  <van-action-sheet
      cancel-text="取消"
      :duration="0.2"
      close-on-click-action
      v-model="show"
      :actions="actions"
      @select="onSelect" />
</div>
</template>

<script>
import { getToken } from "../../../uilts/token";
import { userRenzheng } from "../../../api/user";

export default {
  name: "renzhengform",
  props:{
    obj:Object
  },
  data() {
    return {
      actions: [
        { name: '二手车经理',type:1 },
        { name: '市场总监',type:2 },
        { name: '网点数字营销主管 ',type:2 },
        { name: '销售顾问  ',type:2 },
        { name: '销售内训师  ',type:2 },
        { name: '销售总监   ',type:2 },
        { name: '总经理',type:3 }],
      show:false,
      form:{
        name:"",
        phone:"",
        jobNumber:"",
        code:"",
        company:"", //公司名称
        org:"", //区域
        staffType:"",
        dealerCode:"", //网点编号
        dealerName:"" // 网点名称
      }
    }
  },
  methods: {
    async renzheng(){
      this.form.type = this.obj.type
      this.form.token = getToken()
      console.log(this.form)
      const res = await userRenzheng(this.form)
      console.log(res)
    },
    onSelect(e){
      console.log(e)
      this.form.staffType = e.name
    }
  }
}
</script>

<style scoped>

>>>.van-cell{
  margin: 8px 30px;
  width: auto;
  border-radius: 10px;
}
>>>.van-field__label{
  width: 24px;
  font-size: 24px;
}

.form-footer{
  margin: 16px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.form-footer button{
  width: 80px;
  border-radius: 10px;
}
</style>
